import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;


public class MgFighter implements ActionListener {
	protected int health=100,maxHealth=100;
	protected Image originalImg,hurtImg;
	protected int x,y,movement=1,meleeDamage=1;
	protected Timer hurtTimer;
	protected Image img;
	protected int width,height;
	
	MgFighter(int x,int y,Image originalImg,Image hurtImg) {
		this.maxHealth = health;
		this.originalImg = originalImg;
		this.hurtImg = hurtImg;
		this.x = x;
		this.y = y;
		img = originalImg;
		width = img.getWidth(null);
		height = img.getHeight(null);
		hurtTimer = new Timer(250, this);
		hurtTimer.setActionCommand("hurt");
	}
	public int getX(){
		return x;
	}
	public int getY(){
		return y;
	}
	public Image getImage(){
		return img;
	}
	public int getWidth(){
		return width;
	}
	public int getHeight(){
		return height;
	}
	public int getHealth(){
		return health;
	}
	public int getMaxHealth(){
		return maxHealth;
	}
	/**
	 * Sets the maximum health. Whenever maximum health is set, the current health is upgraded to the max.
	 * @param maxHealth the desired maximum health.
	 */
	public void setMaxHealth(int maxHealth){
		this.maxHealth = maxHealth;
		this.health = maxHealth;
	}
	public boolean hurt(int dmg){
		if(health>0){
			health -= dmg;
			img = hurtImg;
			hurtTimer.start();
			return true;
		}else
			return false;
	}
	public int getMovement(){
		return movement;
	}
	public void setMovement(int movement){
		this.movement = movement;
	}
	public int getMeleeDamage(){
		return meleeDamage;
	}
	public void setMeleeDamage(int meleeDamage){
		this.meleeDamage = meleeDamage;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		img = originalImg;
		hurtTimer.stop();
	}
	public void move(){
		
	}
	public void fire(){
		
	}
	public void setX(int x){
		this.x = x;
	}
	public void setY(int y){
		this.y = y;
	}
}
